<?php
    class Zendvn_Acl_Acl extends Zend_Acl
    {
        public function __construct(){
            // Khai bao cac nhom quyen(role)
            $this->addRole(new Zend_Acl_Role('guest'));
            $this->addRole(new Zend_Acl_Role('member'), 'guest');
            $this->addRole(new Zend_Acl_Role('editor'), 'member');
            $this->addRole(new Zend_Acl_Role('admin'), 'editor');
            
            // Khai bao cac resources cho module Admin
            $this->addResource(new Zend_Acl_Resource('admin:index'));
            $this->addResource(new Zend_Acl_Resource('admin:place'));
            $this->addResource(new Zend_Acl_Resource('admin:role'));
            $this->addResource(new Zend_Acl_Resource('admin:category'));
            $this->addResource(new Zend_Acl_Resource('admin:news'));
            $this->addResource(new Zend_Acl_Resource('admin:newscomment'));
            $this->addResource(new Zend_Acl_Resource('admin:user'));
            $this->addResource(new Zend_Acl_Resource('admin:tour'));
            $this->addResource(new Zend_Acl_Resource('admin:comment'));
            $this->addResource(new Zend_Acl_Resource('admin:orders'));
            
            // Khai bao cac resources cho module Default
            $this->addResource(new Zend_Acl_Resource('default:index'));
            $this->addResource(new Zend_Acl_Resource('default:news'));
            $this->addResource(new Zend_Acl_Resource('default:tour'));
            $this->addResource(new Zend_Acl_Resource('default:user'));
            $this->addResource(new Zend_Acl_Resource('default:contact'));
            
            // Khai bao cac resources cho module Error
            $this->addResource(new Zend_Acl_Resource('error:error'));
            
            // Cap quyen truy cap cho cac nhom
            // Guest
            $this->allow('guest', 'error:error', null);
            $this->allow('guest', 'default:index', null);
            $this->allow('guest', 'default:news', null);
            $this->allow('guest', 'default:tour', null);
            $this->allow('guest', 'default:user', null);
            $this->allow('guest', 'default:contact', null);
            $this->allow('editor', 'admin:index', array('index', 'login', 'logout'));
            
            // Member
            
            // Editor
            $this->allow('editor', 'admin:tour', null);
            $this->allow('editor', 'admin:comment', null);
            $this->allow('editor', 'admin:news', null);
            $this->allow('editor', 'admin:newscomment', null);
            
            // Admin
            $this->allow('admin', 'admin:role', null);
            $this->allow('admin', 'admin:index', null);
            $this->allow('admin', 'admin:place', null);
            $this->allow('admin', 'admin:news', null);
            $this->allow('admin', 'admin:newscomment', null);
            $this->allow('admin', 'admin:user', null);
            $this->allow('admin', 'admin:category', null);
            $this->allow('admin', 'admin:tour', null);
            $this->allow('admin', 'admin:comment', null);
            $this->allow('admin', 'admin:orders', null);
        }
    }
